package club.babyf.nativeai.entity;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

import java.util.Map;

/**
 * FunctionResult.
 *
 * @author zhanglei.
 * @date 2025/2/25 11:18.
 * @description 函数结果.
 */
@Data
public class FunctionResult {

    private final String result;

    private static final ObjectMapper objectMapper = new ObjectMapper();

    public String toJson() {
        try {
            return objectMapper.writeValueAsString(Map.of("result", result));
        } catch (JsonProcessingException e) {
            return "{\"error\":\"结果序列化失败\"}";
        }
    }

}
